﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using LiveEduWizard.Device;

namespace LiveEduWizard.Theme
{
    public class ColorsSet
    {
        private static List<WPColor> colorsList = new List<WPColor>();
        private static Dictionary<string, string> accentColorsNames = new Dictionary<string, string>();

        static ColorsSet()
        {
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Blue), ColorTitle = "blue" });
            accentColorsNames.Add(Blue.ToString(), "blue");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Brown), ColorTitle = "brown" });
            accentColorsNames.Add(Brown.ToString(), "brown");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Green), ColorTitle = "green" });
            accentColorsNames.Add(Green.ToString(), "green");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Lime), ColorTitle = "lime" });
            accentColorsNames.Add(Lime.ToString(), "lime");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Magenta), ColorTitle = "magenta" });
            accentColorsNames.Add(Magenta.ToString(), "magenta");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Orange), ColorTitle = "orange" });
            accentColorsNames.Add(Orange.ToString(), "mango");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Pink), ColorTitle = "pink" });
            accentColorsNames.Add(Pink.ToString(), "pink");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Purple), ColorTitle = "purple" });
            accentColorsNames.Add(Purple.ToString(), "purple");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Red), ColorTitle = "red" });
            accentColorsNames.Add(Red.ToString(), "red");
            colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(Viridian), ColorTitle = "viridian" });
            accentColorsNames.Add(Viridian.ToString(), "viridian");

            if (System.Text.RegularExpressions.Regex.IsMatch(DeviceStatus.DeviceManufacturer, "nokia", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) 
            {
                colorsList.Add(new WPColor { BackgroundColor = new SolidColorBrush(NokiaBlue), ColorTitle = "nokia blue" });
                accentColorsNames.Add(NokiaBlue.ToString(), "nokia blue");
            }
 
        }


        public static List<WPColor> GetColorsSet()
        {
            return colorsList;
        }

        public static string GetColorNameByHexValue(String hexValue) 
        {
            if (accentColorsNames.ContainsKey(hexValue))
            {
                return accentColorsNames[hexValue];
            }
            else
            {
                return String.Empty;
            }
        }

        public static String GetColorTitleByIndex(int colorIndex)
        {
            return colorsList[colorIndex].ColorTitle;

        }

        public static WPColor GetWPColorByIndex(int colorIndex)
        {
            return colorsList[colorIndex];

        }

        public static Color Blue
        {
            get
            {
                return Color.FromArgb(255, 27, 161, 226);
            }
        }

        public static Color Brown
        {
            get
            {
                return Color.FromArgb(255, 160, 80, 0);
            }
        }

        public static Color Green
        {
            get
            {
                return Color.FromArgb(255, 51, 153, 51);
            }
        }

        public static Color Lime
        {
            get
            {
                return Color.FromArgb(255, 162, 193, 57);
            }
        }

        public static Color Magenta
        {
            get
            {
                return Color.FromArgb(255, 216, 0, 115);
            }
        }

        public static Color Orange
        {
            get
            {
                return Color.FromArgb(255, 240, 150, 9);
            }
        }

        public static Color Pink
        {
            get
            {
                return Color.FromArgb(255, 230, 113, 184);
            }
        }

        public static Color Purple
        {
            get
            {
                return Color.FromArgb(255, 162, 0, 255);
            }
        }

        public static Color Red
        {
            get
            {
                return Color.FromArgb(255, 229, 20, 0);
            }
        }

        public static Color Viridian
        {
            get
            {
                return Color.FromArgb(255, 0, 171, 169);
            }
        }

        public static Color NokiaBlue
        {
            get
            {
                return Color.FromArgb(255, 16, 128, 221);
            }
        }

    }

}
